package com.shuoyue.ycgk.ui.mine.vip;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseViewHolder;
import com.shuoyue.ycgk.R;
import com.shuoyue.ycgk.base.baseadapter.AppBaseQuickAdapter;
import com.shuoyue.ycgk.entity.VipPrice;
import com.shuoyue.ycgk.utils.XDateUtils;

import java.util.List;

public class VipAdapter extends AppBaseQuickAdapter<VipPrice> {
    public VipAdapter(@Nullable List<VipPrice> data) {
        super(R.layout.item_vip, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, VipPrice item) {
        helper.addOnClickListener(R.id.lay_all);
        helper.setBackgroundRes(R.id.lay_all,
                item.isSelect() ? R.drawable.vip_selected : R.drawable.vip_unselect);
        helper.setText(R.id.price, String.valueOf(item.getPrice()));
        helper.setText(R.id.time, item.getEffectiveTime() + "天");
        helper.setText(R.id.end_time, item.getValidate());
//        helper.setText(R.id.end_time, String.valueOf(
//                XDateUtils.format(System.currentTimeMillis() + item.getEffectiveTime() * 24 * 60 * 60 * 1000,
//                        "yyyy-MM-dd HH:mm")));
        helper.setVisible(R.id.tag, item.getIsRecommend() == 1);
    }


    public VipPrice getSelect() {
        for (VipPrice vipPrice : mData) {
            if (vipPrice.isSelect()) return vipPrice;
        }
        return null;
    }
}
